package com.orange.core.pojo.entity.user;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.orange.core.pojo.entity.IIntIdModel;
import com.orange.core.pojo.entity.IUpdateModel;
import com.orange.core.pojo.enums.EStatus;
import com.orange.core.pojo.enums.EUserType;
import com.orange.core.validator.group.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.With;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class User implements IIntIdModel<User>, IUpdateModel<User> {

    @NotNull(message = "请求参数不合法", groups = {Update.class})
    @TableId(type = IdType.AUTO)
    private @With Integer id;

    /**
     * 会员编号
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private String userNo;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 状态：0禁用，1启用
     *
     * @see EStatus
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer status;

    /**
     * 用户类型：1用户，2员工，3商管
     *
     * @see EUserType
     */
    private Integer type;

    /**
     * 品牌id，用户为员工/商管时需选择
     */
    private Integer shopId;

    /**
     * 品牌店铺名称
     */
    @TableField(exist = false)
    private String shopName;

    /**
     * 职位，用户类型为员工时填写
     */
    private String position;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 积分
     */
    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private Integer credit;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonIgnore
    private String wxOpenId;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonIgnore
    private String wxUnionId;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime createTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime updateTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Integer updateBy;

    /**
     * 优惠券数量
     */
    @TableField(exist = false)
    private Integer couponCount;

    /**
     * 员工卡号
     */
    @TableField(exist = false)
    private String cardNo;
}
